package com.mes.cloud.web.productpricegroup;

import com.mes.cloud.api.dto.request.productpricegroup.ProductCustomerGroupAddRequest;
import com.mes.cloud.api.dto.request.productpricegroup.ProductCustomerGroupBatchEnableFlagRequest;
import com.mes.cloud.api.dto.request.productpricegroup.ProductCustomerGroupPageListRequest;
import com.mes.cloud.api.dto.request.productpricegroup.ProductCustomerGroupUpdateRequest;
import com.mes.cloud.api.dto.response.productpricegroup.ProductCustomerGroupDto;
import com.mes.cloud.common.CommPager;
import com.mes.cloud.common.JsonResult;
import com.mes.cloud.service.productpricegroup.ProductCustomerGroupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author wxm
 * @email xiaomin.wu1@pactera.com
 * @version 2019-09-24 14:49:07
 */
@Api(tags = "产品客户组", value = "产品客户组接口")
@RestController
@RequestMapping(value = "/productCustomerGroup")
public class ProductCustomerGroupController  {

    private ProductCustomerGroupService productCustomerGroupService;

    @Autowired
    public ProductCustomerGroupController(ProductCustomerGroupService productCustomerGroupService) {
        this.productCustomerGroupService = productCustomerGroupService;
    }

    /**
     * 功能: 产品客户组分页查询
     *
     * @param productCustomerGroupPageListRequest
     * @return JsonResult<CommPager<ProductCustomerGroupDto>>
     */
    @ApiOperation(value = "产品客户组分页查询", notes = "产品客户组分页查询")
    @PostMapping(value = "/pageList")
    public JsonResult<CommPager<ProductCustomerGroupDto>> pageList(@Valid @RequestBody ProductCustomerGroupPageListRequest productCustomerGroupPageListRequest) {
        return productCustomerGroupService.pageList(productCustomerGroupPageListRequest);
    }

    /**
     * 功能: 产品客户组新增
     *
     * @param productCustomerGroupAddRequest
     * @return JsonResult
     */
    @ApiOperation(value = "产品客户组新增", notes = "产品客户组新增")
    @PostMapping(value = "/add")
    public JsonResult add(@Valid @RequestBody ProductCustomerGroupAddRequest productCustomerGroupAddRequest) {
        return productCustomerGroupService.add(productCustomerGroupAddRequest);
    }

    /**
     * 功能: 产品客户组修改
     *
     * @param productCustomerGroupUpdateRequest
     * @return JsonResult
     */
    @ApiOperation(value = "产品客户组修改", notes = "产品客户组修改")
    @PostMapping(value = "/update")
    public JsonResult update(@Valid @RequestBody ProductCustomerGroupUpdateRequest productCustomerGroupUpdateRequest) {
        return productCustomerGroupService.update(productCustomerGroupUpdateRequest);

    }

    /**
     * 功能: 产品客户组查看详情
     *
     * @param id
     * @return JsonResult
     */
    @ApiOperation(value = "产品客户组查看详情", notes = "产品客户组查看详情")
    @ApiImplicitParam(paramType = "Long", name = "id", value = "产品客户组主键", required = true)
    @GetMapping(value = "get/{id}")
    public JsonResult<ProductCustomerGroupDto> get(@PathVariable String id) {
        return productCustomerGroupService.get(id);
    }

    /**
     * 功能: 产品客户组禁用启用
     *
     * @param id
     * @param enableFlag
     * @return JsonResult
     */
    @ApiOperation(value = "产品客户组禁用启用", notes = "产品客户组禁用启用")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "id", required = true),
            @ApiImplicitParam(name = "enableFlag", value = "状态", required = true),
    })
    @GetMapping(value = "/updateEnableFlag/{id}/{enableFlag}")
    public JsonResult updateEnableFlag(@PathVariable String id, @PathVariable String enableFlag) {
        return productCustomerGroupService.updateEnableFlag(id, enableFlag);
    }

    /**
     * 功能: 产品客户组批量启用禁用
     *
     * @param productCustomerGroupBatchEnableFlagRequest
     * @return JsonResult
     */
    @ApiOperation(value = "产品客户组批量启用禁用", notes = "产品客户组批量启用禁用")
    @PostMapping(value = "/batchEnableFlag")
    public JsonResult batchEnableFlag(@Valid @RequestBody ProductCustomerGroupBatchEnableFlagRequest productCustomerGroupBatchEnableFlagRequest) {
        return productCustomerGroupService.batchEnableFlag(productCustomerGroupBatchEnableFlagRequest);
    }
}
